<template>

  <div class="_wz_personnelParameterDetails">
    <Form>
      <table cellpadding="0" cellspacing="0" border="0">
        <colgroup>
          <col width="13%">
          <col width="20%">
          <col width="13%">
          <col width="20%">
          <col width="13%">
          <col width="20%">
        </colgroup>
        <tbody>
        <tr>
          <td style="font-weight: 600;position:relative;text-align: center;font-size: 18px;" colspan="6">{{!!formData.name ? formData.name : '--'}} 人员档案</td>
        </tr>
        <tr>
          <td colspan="2" rowspan="4">
            <div class="demo-upload-list">
              <div style="width: 100%;height: 100%; display: flex;align-items: center;justify-content: center;">
                <Image :src="!!formData.avatar?apiUrl.imgUrl+formData.avatar:'img/zwtpxd.png'" fit="contain" width=100% height=100% preview :preview-list="[!!formData.avatar?apiUrl.imgUrl+formData.avatar:'img/zwtpxd.png']" />
              </div>
            </div>
          </td>
          <td style="text-align: right;font-weight: 600;">人员名称</td>
          <td>{{!!formData.name?formData.name:'--'}}</td>
          <td style="text-align: right;font-weight: 600;">人员性别</td>
          <td>{{!!formData.gender?formData.gender:'--'}}</td>
        </tr>
        <tr>
          <td style="text-align: right;font-weight: 600;">联系电话</td>
          <td>{{!!formData.phone?formData.phone:'--'}}</td>
          <td style="text-align: right;font-weight: 600;">从业类型</td>
          <td>{{!!formData.typeName?formData.typeName:'--'}}</td>
        </tr>
        <tr>
          <td style="text-align: right;font-weight: 600;">身份证号</td>
          <td>{{!!formData.identifyNum?formData.identifyNum:'--'}}</td>
          <td style="text-align: right;font-weight: 600;">入职时间</td>
          <td>{{!!formData.entryTime?formData.entryTime:'--'}}</td>
        </tr>
        <tr>
          <td style="text-align: right;font-weight: 600;">经营企业</td>
          <td>{{!!formData.deptName?formData.deptName:'--'}}</td>
          <td style="text-align: right;font-weight: 600;">经营类型</td>
          <td>{{!!formData.deptTypeName?formData.deptTypeName:'--'}}</td>
        </tr>
        <tr>
          <td style="text-align: right;font-weight: 600;">详细地址</td>
          <td colspan="5">{{!!formData.address ? formData.address : '--'}}</td>
        </tr>


          <td style="font-weight: 600;position:relative;" colspan="6">身份证信息</td>
          <tr>
            <td style="text-align: right;font-weight: 600;">民族</td>
            <td>{{!!coreDriverPerson.personNation ? coreDriverPerson.personNation : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">出生日期</td>
            <td>{{!!coreDriverPerson.personDate ? coreDriverPerson.personDate : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">签发机关</td>
            <td>{{!!coreDriverPerson.personIssuedBy ? coreDriverPerson.personIssuedBy : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">有效期限</td>
            <td>{{!!coreDriverPerson.personValidDate ? coreDriverPerson.personValidDate : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">公民身份证</td>
            <td colspan="3">{{!!coreDriverPerson.personId ? coreDriverPerson.personId : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">家庭住址</td>
            <td colspan="5">{{!!coreDriverPerson.personAddress ? coreDriverPerson.personAddress : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">身份证正面</td>
            <td colspan="2">
              <div class="demo-upload-list">
                <div style="width: 100%;height: 100%; display: flex;align-items: center;justify-content: center;">
                  <Image :src="!!coreDriverPerson.personFrontPic ? apiUrl.imgUrl + coreDriverPerson.personFrontPic:'img/zwtpxd.png'" fit="contain" width=100% height=100% preview :preview-list="[!!coreDriverPerson.personFrontPic ? apiUrl.imgUrl + coreDriverPerson.personFrontPic:'img/zwtpxd.png']" />
                </div>
              </div>
            </td>
            <td style="text-align: right;font-weight: 600;">身份证反面照</td>
            <td colspan="2">
              <div class="demo-upload-list">
                <div style="width: 100%;height: 100%; display: flex;align-items: center;justify-content: center;">
                  <Image :src="!!coreDriverPerson.personBackPic ? apiUrl.imgUrl + coreDriverPerson.personBackPic : 'img/zwtpxd.png'" fit="contain" width=100% height=100% preview :preview-list="[!!coreDriverPerson.personBackPic ? apiUrl.imgUrl + coreDriverPerson.personBackPic:'img/zwtpxd.png']" />
                </div>
              </div>
            </td>
          </tr>

          <tr>
            <td style="font-weight: 600;position:relative;" colspan="6">驾驶证信息</td>
          </tr>
          <tr>
            <td colspan="2" rowspan="4">
              <div class="demo-upload-list">
                <div style="width: 100%;height: 100%; display: flex;align-items: center;justify-content: center;">
                  <Image :src="!!coreDriverLicense.driverPic ? apiUrl.imgUrl + coreDriverLicense.driverPic:'img/zwtpxd.png'" fit="contain" width=100% height=100% preview :preview-list="[!!coreDriverLicense.driverPic ? apiUrl.imgUrl + coreDriverLicense.driverPic:'img/zwtpxd.png']" />
                </div>
              </div>
            </td>
            <td style="text-align: right;font-weight: 600;">驾驶证号</td>
            <td>{{!!coreDriverLicense.driverId ? coreDriverLicense.driverId : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">准驾车型</td>
            <td>{{!!coreDriverLicense.driverClazz ? coreDriverLicense.driverClazz : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">国籍</td>
            <td>{{!!coreDriverLicense.driverNationality ? coreDriverLicense.driverNationality : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">有效年限</td>
            <td>{{!!coreDriverLicense.driverValidFor ? coreDriverLicense.driverValidFor : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">发证单位</td>
            <td>{{!!coreDriverLicense.driverIssuedBy ? coreDriverLicense.driverIssuedBy : '--'}}</td>
            <td style="text-align: right;font-weight: 600;">初次领证日期</td>
            <td>{{!!coreDriverLicense.driverValidFrom ? coreDriverLicense.driverValidFrom : '--'}}</td>
          </tr>
          <tr>
            <td style="text-align: right;font-weight: 600;">有效期限</td>
            <td colspan="3">{{!!coreDriverLicense.driverValidFrom && !!coreDriverLicense.driverValidDate ? coreDriverLicense.driverValidFrom + ' 至 ' + coreDriverLicense.driverValidDate : '--'}}</td>
          </tr>

        <template v-if="coreDriverCertificateList.length > 0">
          <tr>
            <td style="font-weight: 600;position:relative;" colspan="6">资格证信息</td>
          </tr>
          <template v-for="(item,index) in coreDriverCertificateList">
            <tr style="border-top: 3px solid #515a6e;">
              <td colspan="2" rowspan="3">
                <div class="demo-upload-list">
                  <div style="width: 100%;height: 100%; display: flex;align-items: center;justify-content: center;">
                    <Image :src="!!item.certificatePic ? apiUrl.imgUrl + item.certificatePic:'img/zwtpxd.png'" fit="contain" width=100% height=100% preview :preview-list="[!!item.certificatePic ? apiUrl.imgUrl + item.certificatePic:'img/zwtpxd.png']" />
                  </div>
                </div>
              </td>
              <td style="text-align: right;font-weight: 600;">资格证状态</td>
              <td>
                <Tag type="dot" color="success" v-if="item.certificateState == 1">从业</Tag>
                <Tag type="dot" color="warning" v-else>停业</Tag>
              </td>
              <td style="text-align: right;font-weight: 600;">资格证编号</td>
              <td>{{!!item.certificateNumber ? item.certificateNumber : '--'}}</td>
            </tr>
            <tr>
              <td style="text-align: right;font-weight: 600;">身份名称</td>
              <td>{{!!item.certificateDriverTypeName ? item.certificateDriverTypeName : '--'}}</td>
              <td style="text-align: right;font-weight: 600;">资格证类型</td>
              <td>{{!!item.certificateEmployeeCategoryName ? item.certificateEmployeeCategoryName : '--'}}</td>
            </tr>
            <tr>
              <td style="text-align: right;font-weight: 600;">资格证号码</td>
              <td colspan="3">{{!!item.certificateNo ? item.certificateNo : '--'}}</td>
            </tr>
            <tr>
              <td style="text-align: right;font-weight: 600;">初次领证日期</td>
              <td>{{!!item.certificateInitDate ? item.certificateInitDate : '--'}}</td>
              <td style="text-align: right;font-weight: 600;">截至有效日期</td>
              <td>{{!!item.certificateDueDate ? item.certificateDueDate : '--'}}</td>
              <td style="text-align: right;font-weight: 600;">下次培训时间</td>
              <td>{{!!item.certificateTrainDate ? item.certificateTrainDate : '--'}}</td>
            </tr>
          </template>

        </template>

        </tbody>
      </table>
    </Form>


    <Spin size="large" fix v-if="spinShow"></Spin>
  </div>
</template>
<script>


import {getCurrentInstance,inject,nextTick,reactive, toRefs,toRef,onBeforeMount,onMounted,onBeforeUpdate,onUpdated,onBeforeUnmount,onUnmounted, ref,defineComponent,toRaw,watch} from 'vue'
import { useRouter,useRoute } from "vue-router";

import { useMainStore } from '../../store'  //pinia 使用 类似 vuex
import { storeToRefs } from 'pinia'//pinia 使用 类似 vuex
const mainStore = useMainStore() //pinia 使用 类似 vuex

//reactive
export default defineComponent({
  name: 'personnelParameterDetails',//组件名称
  components: {},//组件引用
  props: ['selectData'],//接收来自父组件的数据
  setup (props,context) {


    const apiUrl = inject('$apiUrl'); // 变量全局化 后台地址
    const $axios = inject('$axiosInterceptor');// 变量全局化 axios
    const $ViewUIPlus = inject('$ViewUIPlus');//引用全局组件
    const router = useRouter();//路由跳转使用


    const state = reactive({
      formData: {},//人员数据

      coreDriverPerson:{},//身份认证
      coreDriverLicense:{},//驾驶证信息
      coreDriverCertificateList:[],//从业资格证信息
      spinShow:false,//加载层

    });


    //加载数据
    const loadData = ()=>{
      $axios.post(apiUrl.coreDriverCoreDriverInfo,{uuid:props.selectData.uuid}).then((res) => {
        if (!!res) {
          state.formData = res.data.data;
          state.coreDriverPerson = !!res.data.data.coreDriverPerson ? res.data.data.coreDriverPerson : {};
          state.coreDriverLicense = !!res.data.data.coreDriverLicense ? res.data.data.coreDriverLicense : {};
          state.coreDriverCertificateList = !!res.data.data.coreDriverCertificateList ? res.data.data.coreDriverCertificateList : [];
          //
          // state.formData = res.data.data;//表单
          // let imgList = [];
          // res.data.data.coreTrailerImgList.forEach((k, i) => {
          //   k.imgUrl = that.apiUrl.imgUrl + k.imgUrl
          //   imgList.push(k);
          // })
          // state.formData.imgEntityList = imgList;//res.data.data.imgEntityList;//多图回显
        }
      }).catch((err) => {
        console.log("失败", err)
      })


    }


    // 其他的生命周期
    onBeforeMount (() => {//beforeMount挂载前状态 // console.log("App ===> 相当于 vue2.x 中 beforeMount")

    })
    onMounted (() => {//mounted 挂载结束状态  // console.log("App ===> 相当于 vue2.x 中 mounted")
      loadData()
    })

    // 注意，onBeforeUpdate 和 onUpdated 里面不要修改值
    onBeforeUpdate (() => {//beforeUpdate 更新前状态 // console.log("App ===> 相当于 vue2.x 中 beforeUpdate")

    })

    onUpdated (() => {//updated 更新完成状态 // console.log("App ===> 相当于 vue2.x 中 updated")

    })

    onBeforeUnmount (() => {//beforeDestroy 销毁前状态  // console.log("App ===> 相当于 vue2.x 中 beforeDestroy")
    })

    onUnmounted (() => {//destroyed 销毁完成状态  // console.log("App ===> 相当于 vue2.x 中 destroyed")
    })

    return {
      ...toRefs(state),
      apiUrl,
    }
  }
})


</script>
<style lang="less">

._wz_personnelParameterDetails {
  height: 100%;
  overflow: auto;
  ._wz_contractsData{
    cursor: pointer;
    color: #2d8cf0;
  }

  table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12px !important;

    td {
      min-width: 0;
      height: 40px;
      box-sizing: border-box;
      text-align: left;
      text-overflow: ellipsis;
      border: 1px solid #515a6e;
      padding: 0 10px;
      word-break: break-word;
    }
  }

  .demo-upload-list {
    margin: 5px auto;
    width: 200px;
    height: 140px;
    text-align: center;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    position: relative;

    img {
      min-height: 10%;
      max-height: 90%;
      min-width: 10%;
      max-width: 90%;
      //width: 100%;
      //height: 100%;
    }
  }
  ._wz_type_color_39a4ff:before {
    content: "";
    display: block;
    width: 120px;
    height: 120px;
    border-style: solid;
    border-color: transparent #39a4ff transparent transparent;
    border-width: 30px;
    position: absolute;
    top: -60px;
    left: -60px;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
    z-index: 1;
  }

  ._wz_type_color_39a4ff:after {
    content: attr(data-sub);
    position: absolute;
    top: -36px;
    left: 13px;
    z-index: 2;
    color: #fff;
    -webkit-transform: rotate(315deg);
    transform: rotate(315deg);
    font-size: 12px;
  }



  ._wz_type_color_ff9900:before {
    content: "";
    display: block;
    width: 120px;
    height: 120px;
    border-style: solid;
    border-color: transparent #ff9900 transparent transparent;
    border-width: 30px;
    position: absolute;
    top: -60px;
    left: -60px;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
    z-index: 1;
  }

  ._wz_type_color_ff9900:after {
    content: attr(data-sub);
    position: absolute;
    top: -36px;
    left: 13px;
    z-index: 2;
    color: #fff;
    -webkit-transform: rotate(315deg);
    transform: rotate(315deg);
    font-size: 12px;
  }

}
</style>
